package edu.cuit.avatar.enums;

import java.io.IOException;
import java.util.Scanner;
import java.util.function.Function;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/19 13:45
 */
public class EnumTest {
    public static void main(String[] args) {
        WeekDay weekDay = WeekDay.SAT;

        System.out.println(weekDay); //SAT

        WeekDay nextDay = weekDay.nextDay();
        System.out.println(nextDay);

        MyFavoriteColor color = MyFavoriteColor.YELLOW;
        System.out.println(color);//本身覆盖了toString(),返回的就是字面标识名  YELLOW
        //返回和枚举值关联的序号值。枚举类型中的第一个值具有序号数0，第二个值具有序号值1，第三个为2，以此类推
        System.out.println(color.ordinal()); //3
        System.out.println(color.name()); //返回的就是字面标识名  YELLOW

        System.out.println("请输入你喜欢的颜色:(RED, BLUE, GREEN, YELLOW)");
//        try (Scanner input = new Scanner(System.in)){
//            String favoriteColor = input.next();
//            MyFavoriteColor myFavoriteColor = MyFavoriteColor.valueOf(favoriteColor);
//            System.out.println(myFavoriteColor.ordinal());
//        }

        MyFavoriteColor[] values = MyFavoriteColor.values();
        for(MyFavoriteColor c : values)
            System.out.println(c.name() + "--" + c.ordinal());

        System.out.println("===================================");
        System.out.println(color.getValue());

        System.out.println("====================================");

        TrafficLamp lamp = TrafficLamp.YELLOW;
        System.out.println(lamp.name());
        System.out.println("亮灯时长:" + lamp.getTime());
        System.out.println("下一个交通灯:" + lamp.nextLamp());

    }

    @Deprecated
    public void test(){

    }
}
